//fork函数底层实现
#include<iostream>
#include<unistd.h>
#include <sys/types.h>

int main()
{
    pid_t id = fork();
    if(id < 0)
    {
        std::cerr << "Fork Fail" << std::endl;
        return 1;
    }
    else if(id == 0)
    {
        //Child
        std::cout <<"Child  Process  (Pid:" << getpid() << ")"<< std::endl;
    }
    else
    {
        //Parent
        std::cout << "Parent Process (Pid:" << getpid() <<") Child Pid:" << id<< std::endl;
    }
    return 0;
}